#ifndef _BSP_PORT_H_
#define _BSP_PORT_H_

#include "main.h"
#include "stdio.h"
#include "string.h"
#include "stdbool.h"

#include "bsp_RingBuffer.h"
#include "bsp_Timer.h"

// 开关类枚举
typedef enum
{
    s_CLOSE,   // 关闭
    s_OPEN,    // 打开
    s_ERR = 2, // 错误
} Switch_t;

// typedef enum
//{
//     s_CLOSE = 0, // 关闭
//     s_OPEN = 1,  // 打开
//     s_ERR = 2,   // 错误
// } bsp_SW_t;

typedef enum
{
    BSP_UART1 = 0,
    BSP_UART2,
    BSP_UART3,
    BSP_UART4,
} Bsp_Uart_t;

typedef enum
{
    bsp_TIM01,
    bsp_TIM03,
    bsp_TIM14,
    bsp_TIM16,
    bsp_TIM17,
} bsp_TIMx_t;

typedef enum
{
    bsp_CH1,
    bsp_CH2,
    bsp_CH3,
    bsp_CH4,
    bsp_CH5,
    bsp_CH6,
} bsp_CHANNEL_t;

/************************** 运行指示灯 *********************************/
#define LED_RUN_OPEN LL_GPIO_SetOutputPin(LED_RUN_GPIO_Port, LED_RUN_Pin)   // 打开运行指示灯
#define LED_RUN_SHUT LL_GPIO_ResetOutputPin(LED_RUN_GPIO_Port, LED_RUN_Pin) // 关闭运行指示灯
#define LED_RUN_TOGG LL_GPIO_TogglePin(LED_RUN_GPIO_Port, LED_RUN_Pin)      // 翻转运行指示灯
#define LED_RUN_INPUT LL_GPIO_IsInputPinSet(LED_RUN_GPIO_Port, LED_RUN_Pin) // 读取运行指示灯
/*********************** 电池使能引脚 *******************************/
#define VBAT_EN_OPEN LL_GPIO_SetOutputPin(VBAT_EN_GPIO_Port, VBAT_EN_Pin)    // 打开
#define VBAT_EN_CLOSE LL_GPIO_ResetOutputPin(VBAT_EN_GPIO_Port, VBAT_EN_Pin) // 关闭

/*********************** 充电检测引脚 *******************************/
#define TC_PR_INPUT LL_GPIO_IsInputPinSet(TC_PR_GPIO_Port, TC_PR_Pin) // 检测是否正在充电

#define bsp_mDelay(ms) LL_mDelay(ms)

void bsp_Delay_us(uint32_t us);
void bsp_uart_SendData(Bsp_Uart_t Uart, uint8_t *data, uint16_t datalen);
void bsp_USART_SendBytes(uint8_t *Buf, uint8_t length);
void bsp_USART_DMA_SendBytes(uint8_t *Buf, uint16_t Len);
void bsp_IWDG_ReloadCounter(void);

void bsp_Ctrl_Water_Valve(Switch_t state);
void bsp_Ctrl_Heat_Switch(Switch_t state);
Switch_t bsp_Get_Water_Valve(void);
Switch_t bsp_Get_Heat_Switch(void);
uint8_t bsp_Get_Kettle_State(void);
uint8_t bsp_Get_Spill_State(void);

#endif

// Kettle 水壶
// Water 水
// Heat   //加热
// Valve  //阀门
